const { contextBridge, ipcRenderer, desktopCapturer } = require("electron");
let version = process.versions.electron.split('.')[0] * 1
console.log(version)
let func = {
    on: (key, callback) => {
        ipcRenderer.on(key, (e, d) => {
            callback(d);
        });
    },
    send: (key, value) => {
        ipcRenderer.send(key, value);
    },
    desktopCapturer: () => {
        return desktopCapturer.getSources({ types: ['window', 'screen'] })
    }

}
if (version > 10) {
    contextBridge.exposeInMainWorld("electron", func);
} else {
    process.once('loaded', () => {
        global.electron = func
    })
}